package com.huike.web.controller.clues;

import com.huike.clues.domain.TbClueTrackRecord;
import com.huike.clues.domain.dto.TbClueTrackRecordDTO;
import com.huike.clues.domain.vo.CluePageVo;
import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.domain.vo.TbClueExcelVo;
import com.huike.clues.result.TbClueTrackRecordVO;
import com.huike.clues.service.TbClueTrackRecordService;
import com.huike.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 线索跟进记录Controller
 * @date 2023-04-22
 */
@RestController
@RequestMapping("/clues")
@Slf4j
@RequiredArgsConstructor
@Api(tags = "新增线索跟进记录")
public class TbClueTrackRecordController {

    private final TbClueTrackRecordService tbClueTrackRecordService;

    /**
     * 新增线索跟进记录
     * @return
     */
    @PostMapping("/record")
    @ApiOperation("新增线索跟进记录")
    public Result<ClueTrackRecordVo> clue(@RequestBody TbClueTrackRecordDTO tbClueTrackRecordDTO){
        log.info("线索跟进记录:{}",tbClueTrackRecordDTO);
        ClueTrackRecordVo clueTrackRecordVo = tbClueTrackRecordService.clue(tbClueTrackRecordDTO);
        return Result.success(clueTrackRecordVo);
    }

    /**
     * 查询线索跟进记录列表
     * @return
     */
    @GetMapping("/record/list")
    @ApiOperation("/查询线索跟进记录列表")
    public Result  listResult(@RequestParam Long clueId){
        List<TbClueTrackRecordVO> list =tbClueTrackRecordService.selectTbClueTrackRecordList(clueId);
        return Result.success(list);
    }

    /**
     * 获取线索跟进记录详细信息
     * @param id
     * @return
     */
    @GetMapping("/record/{id}")
    public Result<CluePageVo> list(@PathVariable("id") Long id ){

        log.info("获取线索跟进记录详细信息:{}",id);
        CluePageVo cluePageVo = tbClueTrackRecordService.list(id);
        return Result.success(cluePageVo);


    }
}
